package com.appkubes.fintech.admin.application.order.controller;


import com.appkubes.fintech.admin.application.order.entity.dto.RentOrderDTO;
import com.appkubes.fintech.admin.application.order.entity.vo.RentOrderVO;
import com.appkubes.fintech.admin.application.order.service.RentOrderService;
import com.appkubes.fintech.admin.task.serivce.IPenaltyInterestService;
import com.appkubes.fintech.common.response.Response;
import com.appkubes.fintech.core.po.FintechRentOrder;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@Api(tags = "后台租赁订单")
@RestController
@RequestMapping("rent/order")
public class RentOrderController {
    @Resource
    private IPenaltyInterestService penaltyInterestService;

    @Resource
    private RentOrderService orderService;

    @ApiOperation("跑批任务")
    @GetMapping("/taskBill")
    public Response taskBill() {
        // penaltyInterestService.startPlan();
        penaltyInterestService.penaltyInterest();
        return Response.success();
    }

    @ApiOperation("租赁订单列表")
    @PostMapping("/queryPage")
    public Response<PageInfo<RentOrderDTO>> queryPage(@RequestBody RentOrderVO request) {
        PageInfo<RentOrderDTO> pageInfo = orderService.pageOrder(request);

        return Response.success(pageInfo);
    }

    @ApiOperation("租赁订单列表")
    @PostMapping("/sure")
    public Response sure(@RequestBody RentOrderVO request) {
        return orderService.sureOrder(request);

    }

    @ApiOperation("租赁订单列表")
    @PostMapping("/delete")
    public Response delete(@RequestBody RentOrderVO request) {
        return orderService.deleteOrder(request);
    }

    @ApiOperation("租赁订单列表")
    @GetMapping("/getById")
    public Response<FintechRentOrder> getById(String id) {
        FintechRentOrder order = orderService.getById(id);
        return Response.success(order);
    }

    @ApiOperation("租赁订单列表")
    @GetMapping("/getByUserKey")
    public Response<List<RentOrderDTO>> getByUserKey(String userKey) {
        List<RentOrderDTO> dtoList = orderService.getByUserKey(userKey);
        return Response.success(dtoList);
    }
}
